package com.example.intentactivities;

import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;

public class SecondaryActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_two);
		
		//Get the instance of ActionBar
		ActionBar actionBar = getActionBar();
		
		//Display the "back" arrow on
		//the app icon in the upper left
		//of the ActionBar
		//actionBar.setDisplayHomeAsUpEnabled(true);
		
		//Allow the ActionBar app icon
		//to be clicked
		actionBar.setHomeButtonEnabled(true);
	}
	
	@Override
	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		switch(item.getItemId()){
		case android.R.id.home:
			//The "Up" icon was clicked
			
			//Call finish() to close this Activity
			finish();
			return true;
		}
		return false;
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_secondary, menu);
		return true;
	}

}
